<%@page import="java.util.ArrayList"%>
<%@page import="lib_model.Product.Image_products"%>
<%@page import="lib_model.Product.Tax_product"%>
<%@page import="lib_model.Product.Products"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="UTF-8"%>
<jsp:include page="../templates/Header.jsp"></jsp:include>
Product Detail
<jsp:include page="../templates/Title.jsp"></jsp:include>
<script type="text/javascript">
	$(document).ready(
			function() {
				$(".product").click(function() {
					window.location = "../Cart/AddItemCart?id="+ $(this).attr("productid");
				});
	});
	
</script>
<jsp:include page="../templates/Style.jsp"></jsp:include>
<div class="body-center w960">
<%
	if (request.getParameter("id") != null) {
		Products p = ((Products) (new Products(Integer.parseInt(request
				.getParameter("id")))).GetInformation().ObjResult);
		Tax_product tax = new Tax_product(p.tax_product_id_ref);
%>
<h2 class="title-show"><%=p.name%></h2>
<div style="float: left; width: 180px">
<%
	Image_products img = new Image_products();
		ArrayList<Image_products> imgs = (ArrayList<Image_products>) img
				.Select(p.id).ObjResult;
		int i = 0;
		for (Image_products img2 : imgs) {
			i++;
			if (i == 1) {
%> <img style="border: 1px solid; float: left;"
	src="../uploads/<%=img2.image_url%>" alt="Product Image.." width="175" />
<div class="clear"></div>
<%
	} else {
%> <a href="../uploads/<%=img2.image_url%>" target="_parent"><img
	style="border: 1px solid; float: left; margin-top: 3px; margin-right: 3px;"
	src="../uploads/<%=img2.image_url%>" alt="Product Image.." height="50" /></a>
<%
	}
		}
%>

</div>
<div style="width: 650px; float: left;">
<table class="tb" style="width: 650px;">
	<tr>
		<th width="10%"></th>
		<th></th>
		<th></th>
	</tr>
	<tr>
		<td>Name</td>
		<td><%=p.name%></td>
	</tr>
	<tr>
		<td>Price</td>
		<td><%=p.price%> $</td>
	</tr>
	<tr>
		<td>Tax Product</td>
		<td><%=tax.value%></td>
	</tr>
	<tr>
		<td>Option</td>
		<td><input type="button" class="product" value="Add to Cart"
			productid="<%=p.id%>"><input type="button" value="Like"
			style="background-image: none; color: red; background-color: yellow; text-shadow: none;"></td>
	</tr>
	<tr>
		<td>Description</td>
		<td><%=p.description%></td>
	</tr>
</table>
<INPUT type=button value=" Back " onClick="history.back();"> <%
 	} else {
 %><h2>This product not exist</h2>
<%
	}
%>
</div>
</div>

<div class="clear"></div>

<div class="body-center w960">
<%
	if (request.getParameter("id") != null) {
%>
<h2 class="title-show">Product same type</h2>
<%
	String idCategories = request.getParameter("id").toString();
		Products p = new Products();
		Products p2 = ((Products) (new Products(
				Integer.parseInt(request.getParameter("id"))))
				.GetInformation().ObjResult);
		ArrayList<Products> ps = (ArrayList<Products>) p
				.SelectByIDCategories(p2.categories_id_ref).ObjResult;
		int i = 0;
		for (Products product : ps) {
			i++;
%>
<div class="product-show"
	style="padding: 3px; border: 2px solid; font-size: 12px">
<div
	style="width: 90%; margin: 4px; background-color: #ECC900; padding: 3px; -moz-border-radius: 5px">
<b>Name</b>: <font color="white"><%=product.name%></font><br>

<b>Price</b> : <font color="white"><%=product.price%></font> $<br>
<div class="clear"></div>
</div>
<br>
<%
	Image_products img = new Image_products();
			ArrayList<Image_products> imgs = (ArrayList<Image_products>) img
					.Select(product.id).ObjResult;
			for (Image_products img2 : imgs) {
%> <a href="../pages/product-detail.jsp?id=<%=product.id%>"><img
	style="border: 1px solid;" src="../uploads/<%=img2.image_url%>"
	alt="Product Image.." height="175" width="175" /></a> <%
 	break;
 			}
 %>
<hr />
</div>
<%
	if (i == 5) {
				break;
			}
		}
	} else {
%><h2>This Categories is empty</h2>
<%
	}
%>
</div>
<jsp:include page="../templates/Footer.jsp"></jsp:include>